package com.delivery.www.service.ServiceImpl;

import com.delivery.www.dao.MessageDao;
import com.delivery.www.dao.DaoImpl.MessageDaoImpl;
import com.delivery.www.po.Message;
import com.delivery.www.service.MessageService;
import com.delivery.www.util.JdbcUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class MessageServiceImpl implements MessageService {
    private MessageDao messageDao;

    public MessageServiceImpl() {
        messageDao = new MessageDaoImpl();
    }

    @Override
    public List<Message> getMessage(int storeId) {
        List<Message> messages = null;
        messages = messageDao.getMessage(storeId);
        return messages;
    }

    @Override
    public boolean doMessage(int storeId, String content) {
        boolean flag = false;
        int i = messageDao.doMessage(storeId, content);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public boolean deleteMessage(int messageId) {
        boolean flag = false;
        int i = messageDao.deleteMessage(messageId);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }
}
